@echo off

set proj_name=tmaid
set pwd=%cd%
set home=%pwd%
set build=%home%\%proj_name%
set key=%home%\%proj_name%.pem
set proj_dest=%home%\%proj_name%.crx
set PATH=%PATH%;"C:\Users\rabbithan\AppData\Local\Google\Chrome\Application"

if exist %key% (
	goto build
) else (
	echo key %key% not found
	goto end
)

:build
echo %home%
echo %build%
echo %key%
if exist %proj_dest% (
	rm -dfr %proj_dest%
)
if exist %build% (
	rmdir /S /Q %build%
) 
md %build%
md %build%\_locales
copy *.js %build%
copy *.json %build%
copy *.html %build%
xcopy _locales %build%\_locales /E
chrome --pack-extension=%build% --pack-extension-key=%key%
rmdir /S /Q %build%

:end
:: exit
pause

